package com.om39a.plm.parser;

import org.apache.log4j.Logger;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

import com.om39a.plm.exceptions.NoNextPageException;

/**
 * @author om39a
 * 
 */
public abstract class PLMParser {
	static Logger logger = Logger.getLogger(ParserUserProfilePage.class);

	public String nextPage(String mainContent) throws NoNextPageException {
		logger.info("Entring into parse - mainContent - ");
		String nextPageUrl = null;
		Document doc = Jsoup.parse(mainContent);
		Elements nextPageElement = doc.getElementsByAttributeValue("class",
				"next_page");
		if (null == nextPageElement.attr("href")
				|| "".equals(nextPageElement.attr("href"))) {
			nextPageElement = null;
		} else {
			nextPageUrl = nextPageElement.attr("href");
		}
		logger.info("Exiting from parse");
		return nextPageUrl;
	}

}
